#！sur/bin/env ptyhon3
# -*- coding: utf-8 -*-

def trim(s):
    for i in range(len(s)):
        if s[i] ==' ':
            continue
        else:
            break
    s = s[i:len(s)]
    
    for i in range(len(s)):
        if s[-(i+1)] !=' ':
            break
        else:
            continue
    s = s[:len(s)-i]
    
    return s

ss  = input('请输入字符串：')

print(trim(ss))

print('a',trim('          hello world!'),sep='')

print(trim('Hello world!          '),'a',sep='')



